package javaTest01;

public class FindCompleteNumber {
    public static void main(String[] args) {
        findCompleteNumber(1000);
    }
    public static void findCompleteNumber(int field){//找出范围内的完数
        int count=0;
        for (int i=2;i<=field;i++)
        {
            if (isCompleteNumber(i)){
                count++;
                String str="";
                if (count%10==0)
                    str=i+"\n";
                else
                    str=i+"\t";
                System.out.print(str);
            }
        }
    }
    public static boolean isCompleteNumber(int n){//判断是否为完数
        int sum=0;
        for (int i=1;i<n;i++)
            if (n%i==0)
                sum+=i;
        return sum==n;
    }

}
